import random

from utils import brief


def generate_dataset(size):
    return [random.random() for i in range(size)]


def load_dataset(filepath):
    with open(filepath) as f:
        return [float(each) for each in f]


def save_dataset(dataset, filepath):
    with open(filepath, 'w') as f:
        for each in dataset:
            f.writelines(str(each) + '\n')


if __name__ == '__main__':
    import os
    sizes = [1000, 2000, 5000, 10000, 20000, 50000, 100000]
    for size in sizes:
        s = generate_dataset(size)
        print(brief(s), 'len =', len(s))
        save_dataset(s, os.path.join('datasets', f'dataset-{size}.txt'))
